﻿using Microsoft.EntityFrameworkCore;
using MySpiderMgr.Data.IRepositories.Common;
using MySpiderMgr.Domain.Common;
using MySpiderMgr.Domain.Common.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MySpiderMgr.Data.EF.Repositories.Common
{
    public class SysSequenceRepository : EFRepository<SysSequence>, ISysSequenceRepository
    {
        public List<SysSequence> FindSysSequences(FindSysSequenceFilter Filter)
        {
            var data = this.TableNoTracking;

            if (Filter != null)
            {
                if (Filter.Id.HasValue)
                {
                    data = data.Where(s => s.Id == Filter.Id);
                }
                if (Filter.Ids != null && Filter.Ids.Length > 0)
                {
                    data = data.Where(s => Filter.Ids.Contains(s.Id));
                }
                if (Filter.Name != null)
                {
                    data = data.Where(s => s.Name.Contains(Filter.Name));
                }
            }
            return data.ToList();
        }
        public SysSequence GetById(int Id)
        {
            return this.GetById(Id);
        }
    }
}
